 var id = getvl("id");
 var currentPage=1;
 $(function(){
 	   if(id!=null){
 	   	  selectGoodsList2();
 	   	$("#qaunbu").attr("href","12.8.0buy_dingdan.html?id="+id);
 	   	$("#daifahuo").attr("href","12.8.0buy_dingdan_daifahuo.html?id="+id);
 	   $("#daifukuan").attr("href","12.8.0buy_dingdan_daifukuan.html?id="+id);
 	   $("#daishouhuo").attr("href","12.8.0buy_dingdan_daishouhuo.html?id="+id);
 	   $("#daipingjia").attr("href","12.8.0buy_dingdan_daipingjia.html?id="+id);
 	   }else{
 	   	alert("登录异常...");
 	   }
 });
 var ss=0;
function  selectGoodsList2(){ 
	if(currentPage==1 || ss!=0){
	
		$.ajax({
             url: urlcore + "/api/order/WXselect?current="+currentPage+"&userId="+id+"&status=3&types=1",
            type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
						ss=data.data.length;
					$.each(data.data,function(y,n) {
						  if(n.goodsCarList!=null){
						  var zhuantai="";
						    if(n.status==0){
						    	zhuantai="未付款";
						    }else if(n.status==1){
						    	if(n.tradeStatus==0){
						    		zhuantai="待发货";
						    	}else if(n.tradeStatus==1){
						    		zhuantai="待收货";
						    	}
						    }else if(n.tradeStatus==2){
						    	   if(n.status==3){
						    	   	zhuantai="已评价";
						    	   }else{
						    	   	 zhuantai="未评价";
						    	   }
						    }
						
			var quanbuleirong=
			'<div class="detail_goods clearfix">'+
						'<h4>'+n.shop.storeName+'<span>'+zhuantai+'</span></h4>';
                        
    	              
	          $.each(n.goodsCarList, function(k,m) {
	          	 quanbuleirong+='<div class="clearfix tuwen">'+
                        '<a href="12.8.2buy_dingdan_daishouhuo_detail.html?id='+n.id+'">'+
    	                '<div class="tuwen-img fl">'+
	          	 '<img onerror="errorImg2(this)" src="'+m.goods.coverUrl+'" width="75" height="75">'+
	        '</div>'+
	        '<div class="tuwen-wenzi">'+
	            '<h5 class="wuye_h01">'+m.goods.goodsTitle+'</h5>'+
	         /*   '<div class="wuye_div01">'+m.goodsSimple+'</div>'+*/
	        '</div>'+
        '</a>'+
    '</div>';
              if(m.myStockList!=null){
    	  $.each(m.myStockList, function(q,w) {
           	   quanbuleirong+='<div class="dingdan_fenlei clearfix">'+
    	  '<ul class="fl">';
    		if(w.colour!=null){
    quanbuleirong+='<li>颜色：<span>'+w.colour.colourName+'</span></li>';
    		}
    		if(w.size!=null){
    quanbuleirong+='<li>尺码：<span>'+w.size.sizeName+'</span></li>';			
    		}
    		if(m.packRate!=null){
    quanbuleirong+='<li>单价：<span>'+m.packRate+'元/件</span></li>';
    		}
    quanbuleirong+='</ul>'+
    	'<div class="fr">';
    	 /*     if(n.goodsNumber>=m.tradeNumber){	*/
    	      	quanbuleirong+='<h5>'+(m.packRate*n.goodsNumber)+'元</h5>'+
    		'<h6>'+n.goodsNumber+'件</h6>';
    	 /* }else{
    	     quanbuleirong+='<h5>'+m.goods.packPrice+'元</h5>'+
    		'<h6>'+n.goodsNumber+'件</h6>';
    	      }*/
    	quanbuleirong+='</div>'+
              '</div>';
           });
          }
           
             });
            
            	     if(n.status==0){
		 quanbuleirong+='<div class="dingdan_footer">'+
    	     '<div class="fr">'+
    		'<span class="dingdan_quxiao" onclick="bianhaos('+n.orderNumber+')">取消订单</span>'+
    		'<a href="../12.0.0zhifu_goods.html">去支付</a>'+
    	     '</div>'+
              '</div>'+
               '</div>';
            	    }else if(n.status==1){
						    	if(n.tradeStatus==0){
						    	quanbuleirong+='<div class="dingdan_footer">'+
'    	<div class="fr">'+
'    		<span class="dingdan_tixing">提醒发货</span>'+
'    	</div>'+
'    </div>'+
'</div>';
						    	}else if(n.tradeStatus==1){
					 quanbuleirong+='  <div class="dingdan_footer">'+
'    	<div class="fr">'+
'    		<a href="12.9.2buy_dingdan_tuikuan_shenqing.html?id='+n.id+'" class="dingdan_footer_hui">申请退款</a>'+
'    		<a href="javascript:queren('+n.orderNumber+');" class="dingdan_queren">确认收货</a>'+
'    	</div>'+
'    </div>'+
'</div>';
						    	}
						    }else if(n.tradeStatus==2){
						    	   if(n.status==3){
						    	  quanbuleirong+='<div class="dingdan_footer">'+
'    	<div class="fr">'+
'    		<span class="dingdan_shanchu">删除</span>'+
'    	</div>'+
'    </div>'+
'</div>';
						    	   }else{
						    	 quanbuleirong+=' <div class="dingdan_footer">'+
'    	<div class="fr">'+
'    		<a href="12.8.4buy_dingdan_pingjia.html">去评价</a>'+
'    	</div>'+
'    </div>'+
'</div>';
						    	   }
						    }
						$("#quanbuleirong").append(quanbuleirong);
					}	
			});
			
			      $(function(){
			      	 // 取消订单
    // 弹出
    $(".dingdan_quxiao").on('click',function(){
        $("body").append("<div id='mask'></div>");
        $(".show-quxiao").show();
    })
    //点击关闭
    $(".Quxiao").on('click',function(){
        $(".show-quxiao").hide();
        $("#mask").remove();
    }) 
    
    //提醒发货
    $('.dingdan_tixing').on('click',function(){		
		$(this).html("已提醒").css("background","#f5f5f5");
	});	
    
    
    //确认收货
    // 弹出
    $(".dingdan_queren").on('click',function(){
        $("body").append("<div id='mask'></div>");
        $(".show-queren").show();
    })
    //点击关闭
    $(".Quxiao").on('click',function(){
        $(".show-queren").hide();
        $("#mask").remove();
    }) 
    
    
    //删除
    // 弹出
    $(".dingdan_shanchu").on('click',function(){
        $("body").append("<div id='mask'></div>");
        $(".show-shanchu").show();
    })
    //点击关闭
    $(".Quxiao").on('click',function(){
        $(".show-shanchu").hide();
        $("#mask").remove();
    }) 
			      });
			
					
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}

				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
			
	}
	}
	
//取消订单

function queren(te){
	$("#biaohaos").val("");
	$("#biaohaos").val(te);
}

function  querenquxiao(){
	 var biaohaos=$("#biaohaos").val();  
	 if(biaohaos==''){
	 	alert("出现异常");
	 }else{
   	  $.ajax({
      url: urlcore+"/api/order/cancelOrder?orderNumber="+biaohaos,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					/*selectGoodsList2();
				  alert("取消成功");*/
				 var dangqian=window.location.href;
					window.location.href=dangqian;
				}
		/*console.log(goodslist);*/
			},
			error: function() {
				alert("error");
			}
		});
}
}
